<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>

<html>
<head>
	<title><s:text name="pl.grabar.clinic.client.web.reception.patient.views.patient" /></title>
	<sj:head locale="pl" jqueryui="true" jquerytheme="smoothness"/>
	<style type="text/css">
/* 	.wwlbl { width: 300px; border: 1px solid red; float: left} */
/* 	.wwctrl { width: 300px; border: 1px solid red; float: right} */
/* 	.wwgrp { clear: both;} */ 
/* .wwlbl{float:left;width:65%;overflow:hidden;} */
/* .wwctrl{overflow:hidden;} */


.wwgrp{
   display: block;
   background-color: rgb(200, 200, 200);
   padding: 3px;
   border-radius:5px;
     border:1px dotted blue; 
    margin-right:30px;
    float:left;
}
.wwgrp br { display: none; }

.label{
    float:left;
    margin-right:0px;
    height: 11px;
}
 .wwctrl { 
     border: 1px solid gray;
     margin-left:140px;
     }

	</style>
	
	
</head>
<body>
	<h1>
		<s:if test="patientId != null && !patientId.isEmpty()">
			<s:text name="pl.grabar.clinic.client.web.reception.patient.views.edit.edit-patient">
				<s:param value="existingPatient.firstName" />
				<s:param value="existingPatient.lastName" />
			</s:text>
		</s:if>
		<s:else>
			<s:text name="pl.grabar.clinic.client.web.reception.patient.views.edit.new-patient" />
		</s:else>
	</h1>
	<s:form id="form" namespace="/reception/patient" action="save" >
		<s:hidden id="patientId" name="patientId" />
		
		<div style="font-size: 24px;background-color:menu;"><span style="color: blue">
		<s:text  name="pl.grabar.clinic.client.web.labels.basic-personal-data"/>
		</span></div>
		<s:textfield name="patient.firstName" label="%{getText('pl.grabar.clinic.client.web.labels.firstname')}" />
		<s:textfield name="patient.lastName" label="%{getText('pl.grabar.clinic.client.web.labels.lastname')}" />
		<br></br>
		<s:textfield name="patient.age" label="%{getText('pl.grabar.clinic.client.web.labels.age')}" />
		<s:textfield tooltip="Należy podać K lub M" name="patient.gender" label="%{getText('pl.grabar.clinic.client.web.labels.gender')}" />
		<br></br>
		<s:textfield type="pesel" onchange="validatePesel(this.value)" name="patient.pesel" label="%{getText('pl.grabar.clinic.client.web.labels.pesel')}" />
		<script type="text/javascript">
		jQuery.validator.addMethod("pesel", function(value, element) {
			var pesel = value.replace(/[\ \-]/gi, ''); 
			if (pesel.length != 11) { return false; } else {
			var steps = new Array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3); 
			var sum_nb = 0;
			for (var x = 0; x < 10; x++) { sum_nb += steps[x] * pesel[x];}
			sum_m = 10 - sum_nb % 10;
			if (sum_m == 10) { sum_c = 0; } else { sum_c = sum_m;}
			if (sum_c != pesel[10]) {	return false;}
			}
			return true;	
			}, "Proszę o podanie prawidłowego numeru PESEL");
		
		$("#form").validate({
			  debug: true
			});
		</script>
		
		<div id="wwgrp_save_patient_dateOfBirth" class="wwgrp" class="wwgrp" style="z-index: 15;position: relative;">
			<sj:datepicker name="patient.dateOfBirth" displayFormat="dd.mm.yy" maxDate="0d" yearRange="-110:+0"  label="%{getText('pl.grabar.clinic.client.web.labels.dateofbirth')}" changeMonth="true" changeYear="true"/>
		</div>
		<br></br>
		<s:textfield name="patient.phoneNumber" label="%{getText('pl.grabar.clinic.client.web.labels.phone-number')}" />
		<br></br>
		
		<div style="font-size: 24px;background-color:menu"><span style="color: blue">
		<s:text name="pl.grabar.clinic.client.web.labels.address"/>
		</span></div>
		<s:textfield name="patient.address.province" label="%{getText('pl.grabar.clinic.client.web.labels.adress.province')}"/>
		<br></br>
		<s:textfield name="patient.address.city" label="%{getText('pl.grabar.clinic.client.web.labels.adress.city')}" />
		<s:textfield id="peselId" onchange="valPostCode(this)" tooltip="Format: xx-xxx" name="patient.address.postCode" label="%{getText('pl.grabar.clinic.client.web.labels.adress.post-code')}" />
		<script type="text/javascript">
		function valPostCode(obj){
			var patt = /[0-9]{2}(-)?[0-9]{3}/;
			if(!patt.test(obj.value)){
				$("#peselId").prop("value","");
			}
		}
		</script>
		<br></br>
		<s:textfield name="patient.address.street" label="%{getText('pl.grabar.clinic.client.web.labels.adress.street')}" />
		<s:textfield name="patient.address.streetNo" label="%{getText('pl.grabar.clinic.client.web.labels.adress.street-no')}" />
		<s:textfield name="patient.address.placeNo" label="%{getText('pl.grabar.clinic.client.web.labels.adress.place-no')}" />
		<br></br>

		<s:submit cssClass="button" value="%{getText('pl.grabar.clinic.client.web.buttons.save')}" />
	</s:form>
	
</body>
</html>